<?php

namespace Drupal\shusy_point_product\Entity;

use Drupal\shusy_point_product\ViewsController\Traits\ShusyPointProductOrderStatusTrait;
use Entity;

class ShusyPointProductOrder extends Entity {

  public $id;

  public $vid;

  public $uid;

  public $op_uid;

  public $created;

  public $changed;

  public $is_new_revision;

  public $username;

  public $postalcode;

  public $provincename;

  public $cityname;

  public $countyname;

  public $detailinfo;

  public $nationalcode;

  public $telnumber;

  public $point_product_id = 0;

  public $shipping_type;

  public $point = 0;

  public $amount = 0;

  public $validity = REQUEST_TIME;

  public $status = 0;

  public $express_type_id;

  public $express_number;

  use ShusyPointProductOrderStatusTrait;

  function __construct($values = []) {
    $this->is_new_revision = TRUE;
    parent::__construct($values, 'shusy_point_product_order');
  }

  public function save() {
    $this->changed = REQUEST_TIME;
    if (empty($this->created)) {
      $this->created = REQUEST_TIME;
    }

    $this->op_uid = $GLOBALS['user']->uid;
    if (empty($this->uid)) {
      $this->uid = $GLOBALS['user']->uid;
    }

    return parent::save();
  }

}
